home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
disk
/
upcopy60.zip
/
UMAIN.C00
< prev
next >
Wrap
Text File
|
1996-08-21
|
16KB
|
484 lines
/*
* ╔════════════════════════════════════════╗
* ║ UPCOPY ║
* ║ Copyright (c) 1994-96 L.I.Williams ║
* ║ All rights reserved ║
* ║ Issue 6.0 Date: 22Aug96 ║
* ╚════════════════════════════════════════╝
*
*~ UMAIN.C00
* .C00 9-FEB-94 Iss 0.1 Created by LIW
*~ Entry point main etc.
*~ This UPCOPY source code module is provided for interest mainly
*~ It's the parsing of the command parameters
*~ It handles options almost anywhere, better than some
*~
*/
/************************************************************************
* HISTORY:
* Date Iss Who Comment
* 09-FEB-94 0.1 LIW Created
* 08-MAR-94 1.1 LIW LIW nagware
* 29-MAR-94 2.0 LIW U001 Files system or hidden ignored, read-only skipped
* 29-MAR-94 2.0 LIW U002 /R option to overwrite read-only
* 29-MAR-94 2.0 LIW U003 Add header
* 30-MAR-94 2.0 LIW U006 Fix *.*
* 30-MAR-94 2.0 LIW U007 Show what is happening with /y
* 30-MAR-94 2.0 LIW U008 Use term file(s) specified not path
* 30-MAR-94 2.0 LIW U009 Put message ... New file, no version here
* 30-MAR-94 2.0 LIW U010 /N only new, /-N only common
* 30-MAR-94 2.0 LIW U015 Take out text file detector
* 30-MAR-94 2.0 LIW U016 /e and /o options
* 02-APR-94 2.0 LIW U017 Change /-c to /c
* 27-JUN-94 2.1 LIW U018 /y should not override /f
* 02-AUG-94 3.0 LIW U020 Create directory
* 09-AUG-94 3.0 LIW U021 Add /s option
* 18-MAY-95 3.0 LIW U021 Complete /s. Create USCAN
* 24-MAY-95 3.0 LIW U037 /q as well as /-d
* 01-JUN-95 3.0 LIW U038 disable shareware /s with message
* 18-JUN-95 4.0 LIW Windowed stuff
* 27-JUL-95 4.1 DE U047-U050 Path problems
* 06-AUG-95 4.1 LIW U054 root directory problem
* 12-SEP-95 4.1 LIW U077 header with UPCOPY /b
* 19-SEP-95 4.1 LIW U083 Full stop on registered to message
* 19-SEP-95 4.1 LIW U078 allow up to 9 levels and error
* 21-SEP-95 4.1 LIW U085 unset options in parse
* 01-FEB-96 5.0 LIW U106 Keycode registration
* 26-FEB-96 5.0 LIW U110 Keyfile only registration
* 29-MAR-96 5.0b LIW U118 /cd common directories option
* 30-MAR-96 5.0b LIW U119 disk specified as target
* 19-MAY-96 5.1 LIW U123 remove disk specified as target again
* 06-AUG-96 6.0 LIW U149 copy if size or attributes changed
* 14-AUG-96 6.0 LIW U058 remove duplicate from target /ec
* 21-AUG-96 6.0 LIW U136 + to specify same path
***********************************************************************/
/* Include files: */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <process.h>
#include <ctype.h>
#include <dos.h>
#include <io.h>
#include <sys\types.h>
#include <sys\utime.h>
#include <sys\stat.h>
#include <ext.h>
#include <direct.h>
#include <fcntl.h>
#include <graph.h>
#include <setjmp.h>
#include "keyboard.h"
#include "field.h"
#include "mouse.h"
#include "udef.h00"
#include "uproto.h00"
#include "window.h" /* Window type and window functions */
/***********************************************************************
These are the main global variables which have to be compiled in
somewhere so here will do
***********************************************************************/
#include "uglob.h00"
/***********************************************************************
*
The _dos_getftime routine uses system call 0x57 to get the date and
time that the file identified by handle was last written. The date
and time are returned in the words that date and time, respectively,
point to. The values appear in the DOS date and time format, which
is:
Time Bits Meaning
0-4 Seconds/2 (0-29)
5-10 Minutes (0-59)
11-15 Hours (0-23)
Date Bits Meaning
0-4 Day (1-31)
5-8 Month (1-12)
9-15 Year (1980-2099)
Return Value
If successful, the function returns 0. Otherwise, it returns the DOS
error code and sets errno to EBADF, indicating that an invalid file
handle was passed.
*
* Start of code.
***********************************************************************/
void main(int argc, char *argv[])
{
read_ini(argc); // U106
header(); // U003
no_paths = parse(argc,argv); // sort out command
if (no_paths != 0) // parameters specified?
tostream = TRUE; // yes, go to streamed i/o
if (bopt) // /b option?
tostream = TRUE; // yes, go to streamed i/o
if (wopt) // /w option?
tostream = FALSE; // yes, override, windowed i/o
if (tostream) // batch mode ?
{ // yes
fprintf(stderr,"\n%s\n",headmess); // output header
if (no_paths == 0) // no parameters?
explain(); // output help, terminates with leave
upcrun(); // do upcopy run
if (!sharemode) // registered user thankyou
fprintf(stderr,"%s\n",tailmess);
leave(0); // terminates batch mode
}
/* All that follows is in windowed mode */
dismenu(); // do menued display, does its own exit
}
/***********************************************************************
An UPCOPY run
***********************************************************************/
void upcrun(void)
{
char buffer[80]; // working line store
if (makepaths(path1,path2,&parmp1,&parmp2,buffer)) // make full pathnames
error(buffer); // error message and exit
if (compf && quest) // U017
{
/* Check if FC is available */
_searchenv( "FC.EXE", "PATH", buffer );
if (!*buffer)
{
lprintf("\nWarning: Can't find DOS 'FC' file compare in PATH\n");
lprintf("Ignoring /c option\n");
compf = FALSE; // U017
}
}
if (!quest && twoway && eraseable) // U016
lprintf("\nNote. /e has no effect with /y unless /f is specified.\n");
// \nWarning. New files in %s will be automatically erased.\n
if (!quest && !twoway && eraseable) // U016
lprintf(autoeramess,parmp2.full);
checksub(); // no comment
/* Get the present working directory and drive */
odr = _getdrive();
if (getcwd( owd, _MAX_DIR ) == NULL)
error("Can't find current directory");
outlog("Original dr,dir =%c,%s\n",odr+'@',owd);
if (dironly) // /i option
{
diffend = FALSE; // preset no differences found
summary = TRUE; // no output
rlevel = 0; // set recursion level
scandirs(&parmp1,&parmp2); // look through dir's to output result
if (!diffend) // no differences?
// \nFile(s) specified are the same\n
lprintf(fsamess); // U008
else
// "\nSome file(s) specified are different\n
lprintf(fdifmess);
}
else
{ // normal copying run
summary = FALSE; // with copying
diffend = FALSE; // preset no differences found
rlevel = 0; // set recursion level
scandirs(&parmp1,&parmp2); // look through dir's, copying etc
if (!noinfo) // not /q option
{
// \nChecking result ...\n"
lprintf(chkrmess); // U008
summary = TRUE; // no output
diffend = FALSE; // preset no differences found
rlevel = 0; // set recursion level
scandirs(&parmp1,&parmp2); // look through dir's to double check
if (!diffend) // no differences?
// File(s) specified are now the same\n
lprintf(fasamess); // U008
else
// Some file(s) specified are still different\n
lprintf(fdifmess); // U008
}
}
}
/***********************************************************************
* Sorts out command options etc
***********************************************************************/
int parse(int argc, char *argv[])
{
int i; // working integer
char *arg; // argument pointer
int chopt; // option character found
int chopt1; // another option character
int lno_paths; // local number of file specifiers found
bopt = FALSE; // preset no /b option
wopt = FALSE; // preset no /w option
// U085
commononly = compf = eraseable = dironly = logging = FALSE;
newonly = overold = noinfo = over_rdonly = subdirs = FALSE;
helpout = noinfo = mirrcopy = FALSE;
twoway = quest = TRUE;
lno_paths = 0; // preset no parms
strcpy(path1,"